package com.example.cofeed.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Navigator;

public class BreedSelectAdapter extends BaseQuickAdapter<Navigator, BaseViewHolder> {
    public BreedSelectAdapter() {
        super(R.layout.adapter_breed);
    }

    @Override
    protected void convert(BaseViewHolder helper, Navigator item) {
        if (item.isSelect){
            helper.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.colorAccent));
            helper.setTextColor(R.id.tv_name, mContext.getResources().getColor(R.color.colorWhite));
        }else {
            helper.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.colorWhite));
            helper.setTextColor(R.id.tv_name, mContext.getResources().getColor(R.color.colorTextNormal));
        }

        helper.setText(R.id.tv_name, item.title);

    }

    public void setSelect(Navigator select){
        for (Navigator navigator:getData()){
            navigator.isSelect = false;
        }
        select.isSelect = true;
        notifyDataSetChanged();
    }
}
